#include<iostream>

using namespace std;
long long a,b,ans=0;

int main()
{
    cin>>a>>b;

    while(a>b){
            if(a%2==0){
                 a/=2;
            }
       else a++;
        ans++;
    }
    ans+=(b-a);
    cout<<ans<<endl;
    return 0;
}
